﻿package kliment.display.draw.shape {
	import flash.geom.Point;
	import kliment.display.draw.DrawStyle;
	
	/**
	 * ...
	 * @author Kliment
	 */
	public class PolyShape extends ShapeAbstract {
		
		public function PolyShape(center:Point, sides:int = 5, radius:Number = 100, angle:Number = 0, drawStyle:DrawStyle = null) {
			super();
			var count:int = Math.abs(sides);
			if (count > 2) {
				var step:Number = (Math.PI * 2) / sides; 
				var start:Number = (angle / 180) * Math.PI; 
				var dx:Number, dy:Number;
				_setStyles(graphics, drawStyle);
				graphics.moveTo(center.x+(Math.cos(start)*radius), center.y-(Math.sin(start)*radius));
				for (var n:Number = 1; n <= count; n++) {
					dx = center.x + Math.cos(start + (step * n)) * radius;
					dy = center.y - Math.sin(start + (step * n)) * radius;
					graphics.lineTo(dx, dy);
				}
				graphics.endFill();
			}
		}
		
	}
	
}